import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { crx } from "@crxjs/vite-plugin";
import zipPack from "vite-plugin-zip-pack";
import manifest from "./manifest.json";
import path from "path";

export default defineConfig({
  plugins: [
    vue(), 
    crx({ manifest }),
    // 添加压缩插件配置
    zipPack({
      inDir: 'dist',         // 要压缩的目录
      outDir: '.',           // 输出zip文件的目录
      outFileName: 'dist.zip' // 输出的zip文件名
    })
  ],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
    extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"],
  },
  build: {
    outDir: "dist",
    emptyOutDir: true,
    rollupOptions: {
      output: {
        chunkFileNames: "assets/chunk-[hash].js",
      },
    },
  }
});
